package com.szhuang.mobilesafe.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Switch;
import android.widget.TextView;

import com.szhuang.mobilesafe.R;

/**
 * Created by szhuang on 2015/3/21.
 */
public class SettingItemView extends RelativeLayout {

    TextView tv_title;
    TextView tv_desc;
    Switch status;
    private boolean isChecked;

    private void initView(Context context) {
        View.inflate(context, R.layout.activity_setting_item, this);
        status = (Switch) findViewById(R.id.status);
        tv_desc = (TextView) findViewById(R.id.tv_desc);
        tv_title = (TextView) findViewById(R.id.tv_title);
    }

    public SettingItemView(Context context, AttributeSet attributeSet, int defStyle) {
        super(context, attributeSet, defStyle);
        initView(context);
    }

    public SettingItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        initView(context);
    }


    public boolean isOpen(){
        boolean result=false;
        if(status.isChecked()){
            result=true;
        }else {
            result=false;
        }
        return result;
    }



    public void setChecked(boolean bool){
        status.setChecked(bool);
    }

    public void setDesc(String str){
        tv_desc.setText(str);
    }

    public void setTitle(String str){
        tv_title.setText(str);
    }

}
